package com.xiang.community.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;

/**
 * @author qixiangLi
 * @Date 2021/11/11
 */
@Slf4j
@ControllerAdvice(annotations = Controller.class)
public class MyExceptionHandler {
    @ExceptionHandler
    public void handleException(Exception e, HttpServletRequest request) {
        log.error("访问 {} with 参数:{},发生错误:{}", request.getRequestURL().toString(),
                request.getParameterMap().toString(), e.toString());
        e.printStackTrace();
    }
}
